home *** CD-ROM | disk | FTP | other *** search
- Path: cscsun3.larc.nasa.gov!hook
- From: hook@cscsun3.larc.nasa.gov (Ed Hook)
- Newsgroups: comp.lang.c
- Subject: Re: HELP: Illegal Pointer Arithmetic
- Date: 25 Feb 1996 20:59:22 GMT
- Organization: CSC/NASA Langley Research Center
- Distribution: world
- Message-ID: <4gqija$bmo@reznor.larc.nasa.gov>
- References: <4gj0ug$730@news.one.net> <danpop.825121139@rscernix> <31306a18.309961701@nntp.ix.netcom.com> <4gq77b$bmo@reznor.larc.nasa.gov>
- Reply-To: hook@cscsun3.larc.nasa.gov
- NNTP-Posting-Host: cscsun3.larc.nasa.gov
-
- Following up to myself:
-
- In article <4gq77b$bmo@reznor.larc.nasa.gov>, hook@cscsun3.larc.nasa.gov (Ed Hook) writes:
- |> In article <31306a18.309961701@nntp.ix.netcom.com>, miker3@ix.netcom.com (Mike Rubenstein) writes:
-
- [ *deletia* ]
- |> |>
- |> |> Not quite that, but Shildt's Annotated ANSI C Standard says
- |> |>
- |> |> The following fragment illustrates how files are commonly
- |> |> read:
- |> |>
- |> |> do {
- |> |> ch = fgetc(fp);
- |> |> /* ... */
- |> |> } while (!feof(fp));
- |> |>
- |> |> Come on Dan. You're slipping. Surely you could have guessed who
- |> |> teaches this idiocy.
- |> |>
- |> It depresses me to have to defend Schildt, but that loop actually
- |> works as advertised. (I *do* question his use of "commonly", since
- |> I have encountered _any_ code that does it that way ... .) Anyhow,
- |> since 'feof()' is called *after* each iteration of the loopbody,
- |> the loop terminates precisely after the last character is fetched
- |> from the file.
- |>
- Blair Houghton gently pointed out to me (_via_ e-mail) that the above
- defense of Schildt is *erroneous*, since the code in question fails on
- an _empty_ input file. Overall, I feel somehow _cleaner_ now ...
-
- |> |>
- |> |> Michael M Rubenstein
- |>
- |> --
- |> Ed Hook | Coppula eam, se non posit
- |> Computer Sciences Corporation | acceptera jocularum.
- |> NASA Langley Research Center | Me? Speak for my employer?...<*snort*>
- |> Internet: hook@cscsun3.larc.nasa.gov | ... Get a _clue_ !!! ...
-
- --
- Ed Hook | Coppula eam, se non posit
- Computer Sciences Corporation | acceptera jocularum.
- NASA Langley Research Center | Me? Speak for my employer?...<*snort*>
- Internet: hook@cscsun3.larc.nasa.gov | ... Get a _clue_ !!! ...
-